package com.example.smartcity_poverty.ui.poverty.adapter

import android.content.Intent
import android.widget.ImageView
import com.example.smartcity_poverty.Base.BaseRecyclerAdapter
import com.example.smartcity_poverty.R
import com.example.smartcity_poverty.ui.poverty.activity.FourShowActivity
import com.example.smartcity_poverty.ui.poverty.model.PtFourEntity
import kotlinx.android.synthetic.main.re_item_poverty_four.*
import kotlinx.android.synthetic.main.re_item_poverty_four.view.*

/**
 *  created by ikun
 *  ANDROID STUDIO - version 4.0
 *  email: jinkunwei41@gmail.com
 * --------------------------------
 *  案例发布列表适配器
 **/
class PtFourAdapter(
    val list: MutableList<PtFourEntity>,
    val layoutId: Int
) : BaseRecyclerAdapter<PtFourEntity>(list, layoutId) {
    override fun setData(
        view: BaseViewHolder.ViewFind,
        data: PtFourEntity,
        position: Int,
        holder: BaseViewHolder
    ) {
        if (list.size <= 0){

        }else{
            val d = list[position]
            holder.viewFind.fourImageView.setImageResource(d.fourImage)
            holder.viewFind.fourTitle.text = d.fourTitle
            holder.viewFind.fourContent.text = d.fourContent

            val con = holder.viewFind.view?.context
            holder.itemView.setOnClickListener {
                con?.startActivity(Intent(con, FourShowActivity::class.java).apply {
                    putExtra("image", d.fourImage)
                    putExtra("title", holder.itemView.fourTitle.text.toString())
                    putExtra("content", holder.itemView.fourContent.text.toString())
                })
            }
        }

    }


}